//
//  CommonShopsTableViewController.m
//  Sydeny
//
//  Created by Rainbow on 8/14/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "CommonShopsTableViewController.h"


@implementation CommonShopsTableViewController
@synthesize title;

- (id)initWithRequsetParams:(NSDictionary *)params withTitle:(NSString *)aTitle RequestType:(SydenyRequestType)type;
{
    self = [super initWithNibName:@"SDShopsTableViewController" bundle:nil];
    if (self) {
        self.title = aTitle;
        self.requestType = type;
        if (requestParams == nil) {
            requestParams = [[NSMutableDictionary alloc] init];
        }
        [requestParams setValuesForKeysWithDictionary:params];
        [[ServiceHelper sharedService] requestServerForMethod:self.requestType WithParameters:requestParams AndCallBackScope:self AndSuccessSel:@"getShopsSuccess:" AndFailedSel:@"getShopsFailed:"];
    }
    return self;
}

- (void)dealloc
{
    [title release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.navigationItem.title = self.title;
    
    // Do any additional setup after loading the view from its nib.
    UIButton *backBtn = [[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 30)] autorelease];
    [backBtn setBackgroundImage:[UIImage imageNamed:@"back_btn.png"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(tapBackBtn) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setTitle:@"返回" forState:UIControlStateNormal];
    [backBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
    backBtn.titleLabel.font = [UIFont boldSystemFontOfSize:12];
    UIBarButtonItem *backItem = [[[UIBarButtonItem alloc] initWithCustomView:backBtn] autorelease];
    self.navigationItem.leftBarButtonItem = backItem;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return nil;
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void)tapBackBtn
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
